fix(material-experimental/mdc-chips) Replace default values #19006
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
mat-chip-grid implements ControlValueAccessor. Its default value
right now is undefined; once a chip is added, its value is an array
of all the chip values. The default value for a given chip is all the
text content inside the chip. For chips with icons, this causes the
icon text to be included in the value, so a row chip using matChipRemove
would have a value like " hello cancel ". (There's also some unwanted
whitespace in the textContent).
Replace undefined with an empty array, and the textContent with just
the actual chip text, which in the case of row chips corresponds to the
text that the user entered.
These unintuitive values are the same as the old non-mdc
mat-chip-listbox. But due to the way the old listbox implemented
ControlValueAccessor, chips being used as a chip grid didn't actually
ever call the onChange handler to update the FormControl value, so their
values were basically ignored.